<?php

return array(
    'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/',
                    'defaults' => array(
                        'controller' => 'product-controller',
                        'action' => 'index'
                    )
                )
            ),
            'product' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/product',
                    'defaults' => array(
                        'controller' => 'product-controller',
                        'action' => 'index'
                    )
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'product-by-type' => array(
                        'type' => 'Segment',
                        'options' => array(
                            'route' => '/[:type][/:type_name]',
                            'constraints' => array(
                                'type' => '[1-3]',
                                'type_name' => '[a-z-(.html)?]*'
                            ),
                            'defaults' => array(
                                'controller' => 'product-controller',
                                'action' => 'list-product-by-type'
                            )
                        )
                    ),
                    'product-detail' => array(
                        'type' => 'Segment',
                        'options' => array(
                            'route' => '/detail[/:product_id]-[:product_name]',
                            'constraints' => array(
                                'product_id' => '[0-9]*',
                                'product_name' => '[a-z0-9-(.html)?]*'
                            ),
                            'defaults' => array(
                                'controller' => 'product-controller',
                                'action' => 'product-detail'
                            )
                        )
                    ),
                    'product-by-category' => array(
                        'type' => 'Segment',
                        'options' => array(
                            'route' => '/list[/:cat_id][/:cat_name][/sx-:maker_name][/price-:order_by][/price/:price_step][/page-:page]',
                            'constraints' => array(
                                'cat_id' => '[0-9]*',
                                'cat_name' => '[a-z-(.html)?]*',
                                'page' => '[0-9]*',
                                'order_by' => 'up|down',
                                'price_step' => '([0-9]*)-([0-9]*)'
                            ),
                            'defaults' => array(
                                'controller' => 'product-controller',
                                'action' => 'list-product-by-category',
                                'page' => 1,
                                'order_by' => 'up',
                                'maker_name' => 'all',
                                'price_step' => '0-0'
                            )
                        )
                    ),
                    'search' => array(
                        'type' => 'Segment',
                        'options' => array(
                            'route' => '/tim-kiem[/:keyword][/page/:page]',
                            'defaults' => array(
                                'controller' => 'product-controller',
                                'action' => 'search',
                                'keyword' => 'all',
                                'page' => 1
                            )
                        )
                    )
                )
            )
        )
    ),
    'controllers' => array(
        'invokables' => array(
            'product-controller' => 'Product\Controller\ProductController'
        )
    ),
    'view_manager' => array(
        'template_map' => array(
            'header' => __DIR__ . '/../view/header/header.phtml',
            'slider' => __DIR__ . '/../view/slider/slider.phtml',
            'category' => __DIR__ . '/../view/product/category.phtml',
            'product-maker' => __DIR__ . '/../view/product/maker.phtml',
            'price-step' => __DIR__ . '/../view/product/price-step.phtml',
            'welcome' => __DIR__ . '/../view/header/welcome.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);
